package com.gallery.controllers;

import com.gallery.dao.UserDAO;
import com.gallery.models.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

@Controller
public class AuthorizationController {

    UserDAO userDAO;
    @Autowired
    public void setUserDAO(UserDAO userDAO) {
        this.userDAO = userDAO;
    }

    @RequestMapping(value = "/authorization")
    public String authorization(Model model) {
        User registrationUser = new User();
        User authorizationUser = new User();
        model.addAttribute("registrationUser",registrationUser);
        model.addAttribute("authorizationUser",authorizationUser);
        return "authorization";
    }

    @RequestMapping(value = "/registration", method = RequestMethod.POST)
    public String registration(@ModelAttribute ("registrationUser") User user) {
        user.setRole("user");
        userDAO.registerNewUser(user);
        return "redirect:/home";
    }

    @RequestMapping(value = "/login")
    public void login(){}

    @RequestMapping (value ="/password")
    public void password(){}

    @RequestMapping (value ="/Email")
    public void Email(){}

    @RequestMapping (value ="/Name")
    public void Name(){}

    @RequestMapping (value = "/Surname")
    public void Surname (){}

    @RequestMapping (value = "/About")
    public void About () {}


}


